package com.kaluli.project.repository.impl;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import org.springframework.stereotype.Repository;

import com.kaluli.project.domain.entity.CpsVO;
import com.kaluli.project.domain.entity.KllOrderDataVo;
import com.kaluli.project.domain.entity.KllUserDataVo;
import com.kaluli.project.domain.entity.LipinkaVO;
import com.kaluli.project.domain.entity.StockVO;
import com.kaluli.project.domain.repository.KllCpsRepository;
import com.kaluli.project.domain.repository.KllDataRepository;
import com.kaluli.project.domain.repository.KllLipinkaRepository;
import com.kaluli.project.domain.repository.KllStockRepository;
import com.kaluli.system.repository.AbstractRepositorySupport;

@Repository
public class KllLipinkaRepositoryImpl extends AbstractRepositorySupport<LipinkaVO> implements KllLipinkaRepository{

	@Override
	protected Class<LipinkaVO> getEntityClass() {
		// TODO Auto-generated method stub
		return LipinkaVO.class;
	}

	
	@Override
	public List<LipinkaVO> findLipinka(String orderNumber) {
		StringBuffer sql = new StringBuffer(" SELECT c.id, k.title,k.for_what as forWhat,k.amount,k.updated_at as updatedAt,k.created_at as createdAt,k.apply_user_id as apply,k.verify_user_id as verify,c.card_limit as cardLimit ");
		sql.append(" FROM kll_main_order_attr m,kll_lipinka k,`kll_lipinka_card` c   ");
		sql.append(" WHERE m.`coupon_id`=c.`id` and c.lipinka_id = k.id and m.order_number = "+orderNumber);
		List<LipinkaVO> list = excuteSql(sql.toString());
		if(list != null && list.size()>0){
			if(list.get(0) == null){
				return null;
			}
		}
		return list;
	}
	
	
	
	
	

}
